package com.homegoods.orderinfodetail.ui.activity;

import android.annotation.SuppressLint;
import android.os.Bundle;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.homegoods.orderinfodetail.R;
import com.homegoods.orderinfodetail.databinding.InfoActivityGoodsCommentListBinding;
import com.homegoods.orderinfodetail.presenter.GoodsCommentListPresenter;
import com.homegoods.aroutercomment.ARouterPath;
import com.jakewharton.rxbinding2.widget.RxRadioGroup;
import com.kedll.library.base.KRefreshListActivity;

/**
 * @author QiQi
 * @description 商品评价列表
 */
@Route(path = ARouterPath.PATH_GOODS_COMMENT_LIST)
public class GoodsCommentListActivity extends KRefreshListActivity<InfoActivityGoodsCommentListBinding, GoodsCommentListPresenter> {

    @Autowired
    public String id;

    @Override
    public int getLayout() {
        return R.layout.info_activity_goods_comment_list;
    }

    @Override
    protected void initToolBar(Bundle savedInstanceState) {
        super.initToolBar(savedInstanceState);
        setTitle("商品评价");
    }

    @Override
    protected GoodsCommentListPresenter getPresenter() {
        return new GoodsCommentListPresenter(this, id);
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        super.initData(savedInstanceState);
        ARouter.getInstance().inject(this);
    }


    @SuppressLint("CheckResult")
    @Override
    protected void initEvent() {
        RxRadioGroup.checkedChanges(mBinding.rgComment)
                .subscribe(radioBtnId -> {
                    if (radioBtnId == R.id.rb_all) {
                        mPresenter.loadAll();
                    } else if (radioBtnId == R.id.rb_image) {
                        mPresenter.loadImage();
                    }
                });
    }

}
